package cn.tedu.apps_system.controller;

import cn.tedu.apps_system.base.response.JsonResult;
import cn.tedu.apps_system.pojo.dto.OrderCreateRequestDto;
import cn.tedu.apps_system.pojo.dto.OrderReviseDto;
import cn.tedu.apps_system.service.OrderService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpSession;

@Api(tags = "04.订单模块")
@RestController
@RequestMapping("/api/v1/order/")
public class OrderController {
    @Autowired
    private OrderService orderService;


    @ApiOperation("创建订单功能")
    @ApiOperationSupport(order = 10)
    @PostMapping("private/create")
    public JsonResult create(@RequestBody OrderCreateRequestDto request, @ApiIgnore HttpSession session) {
        return orderService.createOrder(request,session);
    }

    @ApiOperation("修改订单状态功能")
    @ApiOperationSupport(order = 20)
    @PostMapping("private/revise")
    public JsonResult revise(@RequestBody OrderReviseDto orderReviseDto, @ApiIgnore HttpSession session) {
        return orderService.reviseOrder(orderReviseDto,session);
    }

    @ApiOperation("删除订单功能")
    @ApiOperationSupport(order = 30)
    @PostMapping("public/delete")
    public JsonResult delete(@RequestBody OrderReviseDto orderReviseDto, @ApiIgnore HttpSession session) {
        return orderService.delete(orderReviseDto,session);
    }

    @ApiOperation("查询订单状态功能")
    @ApiOperationSupport(order = 40)
    @GetMapping("public/select")
    public JsonResult select(@RequestBody OrderReviseDto orderReviseDto, @ApiIgnore HttpSession session) {
        return orderService.select(orderReviseDto,session);
    }

    @ApiOperation("查询所有订单功能")
    @ApiOperationSupport(order = 50)
    @GetMapping("public/selectAll")
    public JsonResult selectAll(@RequestBody OrderReviseDto orderReviseDto, @ApiIgnore HttpSession session) {
        return orderService.selectAll(orderReviseDto,session);
    }
}
